<?php 
      session_start();
        if(!$_SESSION['log']){session_destroy();
        echo "<meta http-equiv='refresh' content='1;url=index.php'>";
      }
      ?>

<!DOCTYPE HTML SYSTEM>
<html>
<head>
<title>Capacity</title>
</head>
<body>
<a href="index.php">1. krok</a>
<a href="form2.php">2. krok</a>
<a href="form3.php">3. krok</a>
<a href="form4.php">4. krok</a>
<a href="out.php">5. krok</a>


    <form action="form2.php" method="get">


	<br/><br/>

	<label for="capacity"> Objem motoru (zadejte 1,2,3) </label>
	<input type="text" id="capacity" name="capacity" value="<?php echo $_GET['capacity'];?>">
		


	<input type="submit" value="Next">
</form>
</body>
<html>


         <?php
$con=mysql_connect("localhost","reimemic","kee7baef");
// Check connection
if (!$con)
  {
  echo "Failed to connect to MySQL: " . mysql_connect_error();
  }

// Create database
mysql_select_db("reimemic");


include("Validator.php");
	 if (!empty($_GET)){
	$pole = array();
 $name =mysql_query("SELECT * FROM TrololoObjem WHERE 1", $con) ; 			                                                 
while ($current=mysql_fetch_array($name)){
$cmp=intcmp($current["Objem"],$_GET['capacity']);

   if($cmp==0 || strlen($_GET['capacity'])>1){
   $objem=$_GET['capacity'];
   $cenaobjem=$current["Cena"];
 
   $true=1;
   } 
   else if(($cmp!=0 && true!=1)|| strlen($_GET['capacity'])<1){
   	$pole['name'] = 'Zadan spatny objem';}
    
    }
    }
	
  if (isset($pole)){
	if (!empty($pole)){

	
		foreach ($pole as $a){
			echo "<div>  " . $a . "</div><br/>";
		}

	}
  else{
    
   
  $_SESSION['capacity']=$objem;
 
  $_SESSION['cenaobjem']=$cenaobjem;


       echo "<meta http-equiv='refresh' content='1;url=form3.php'>";
  }
  }
